#!/bin/bash
# concurrent_pressure_test.sh

echo "=== 高并发连接压力测试 ==="

TARGETS=(
    "43.135.186.249:腾讯云-硅谷"
    "157.230.165.12:DigitalOcean-旧金山"
)

# 测试不同并发级别
CONCURRENCY_LEVELS=(1000 3000 5000 8000 10000)

for target_info in "${TARGETS[@]}"; do
    IP=$(echo $target_info | cut -d: -f1)
    NAME=$(echo $target_info | cut -d: -f2)
    
    echo -e "\n🔥 测试 $NAME 的高并发性能:"
    
    for conc in "${CONCURRENCY_LEVELS[@]}"; do
        echo "并发数: $conc"
        
        # 使用wrk进行HTTP压力测试
        wrk -t12 -c$conc -d30s --timeout 10s http://$IP/ 2>&1 | \
            grep -E "Requests/sec|Latency" | \
            sed 's/^/  /'
        
        # 让服务器休息一下
        sleep 10
    done
done